﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace ACServerSelfHost
{
    class WebAppHost : WebAppHostBase
    {
        public WebAppHost(Uri baseAddress)
            : base(baseAddress)
        {
            Name = "ApiHost";
            Initialize();
        }

        private void Initialize()
        {
            CommandList.Add(new SimpleCommand(Properties.Resources.CommandStopDescription, new string[] { "stop", "quit", "exit", "/q" }, (x) => { State = HostStates.Stop; ; }));
            CommandList.Add(new SimpleCommand(Properties.Resources.CommandRestartDescription, new string[] { "restart", "/r" }, (x) => { State = HostStates.Restart; }));
            CommandList.Add(new SimpleCommand(Properties.Resources.CommandShowUIDescription, new string[] { "showui", "/ui" }, (x) =>
                {
                    System.Diagnostics.Process.Start(BaseAddress.ToString());
                    RaiseLogNotification(string.Format(CultureInfo.CurrentCulture, Properties.Resources.CommandShowUIMessage, BaseAddress.ToString()), Log.Target.Info);
                }));
            CommandList.Add(new SimpleCommand(Properties.Resources.CommandJokeDescription, new string[] { "joke" }, (x) => { RaiseLogNotification( Properties.Resources.CommandJokeMessage, Log.Target.Info); }));
            CommandList.Add(new SimpleCommand(Properties.Resources.CommandVersionDescription, new string[] { "version", "about" },
                (x) =>
                {
                    RaiseLogNotification(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
                    RaiseLogNotification(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                })
            );

            base.AddCommandHelp();
        }
    }
}
